package com.wg.wuge.dto;

import lombok.Data;

@Data
public class ResulTData<T> {

    private Integer code;

    private T data;

    private String msg;

    public static <T> ResulTData<T> success(T data) {
        ResulTData<T> result = new ResulTData<T>();
        result.setCode(200);
        result.setData(data);
        result.setMsg("success");
        return result;
    }

    public static <T> ResulTData<T> error(String msg) {
        ResulTData<T> result = new ResulTData<T>();
        result.setCode(500);
        result.setData(null);
        result.setMsg(msg);
        return result;
    }

    public static <T> ResulTData<T> error(Integer code, String msg) {
        ResulTData<T> result = new ResulTData<T>();
        result.setCode(code);
        result.setData(null);
        result.setMsg(msg);
        return result;
    }

    public static ResulTData success() {
        return success(null);
    }
}
